@var content = {
<link rel="stylesheet" href="${ctxPath}/static/plus/x-admin/css/login.css">
<div class="login-bg">
    <div class="login layui-anim layui-anim-up">
        <div class="message"><strong>MP</strong>管理登录</div>
        <div id="darkbannerwrap"></div>
        <form action="#" method="POST" class="form-horizontal" role="form" id="login-form">
            <div class="form-group">
                <div class="col-sm-12">
                    <input type="text" class="form-control" id="username" name="username"
                           placeholder="输入用户名" required data-bv-notempty-message="用户名不为空"
                           pattern="^.{2,10}$" data-bv-regexp-message="用户名在两到十个字符之间" value=""/>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-12">
                    <input type="password" class="form-control" id="password" name="password"
                           placeholder="输入密码" required data-bv-notempty-message="密码不为空"
                           pattern="^.{1,20}$" data-bv-regexp-message="密码在一到二十个字符之间" value=""/>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-12 text-right">
                    <div class="checkbox">
                        <label>
                            <input type="checkbox" value="1" name="rememberMe" id="rememberMe">记住我
                        </label>
                    </div>
                </div>
            </div>
        </form>
        <button ele-range type="button" class="btn btn-block btn-success" onclick="view.login()"
                id="btn-login">
            登 录
        </button>
    </div>
    <script type="text/javascript">
        $(function () {
            view.init();
        });
        var view = {
            init: function () {
                if ($.cookie('username')) {
                    $('#username').val($.cookie('username'));
                }
                if ($.cookie('password')) {
                    $('#password').val($.cookie('password'));
                    $('#rememberMe').attr('checked', 'checked');
                }

                $('#login-form').bootstrapValidator({
                    message: '值不能为空',
                    feedbackIcons: {
                        valid: 'glyphicon glyphicon-ok',
                        invalid: 'glyphicon glyphicon-remove',
                        validating: 'glyphicon glyphicon-refresh'
                    }
                });
                var that = this;
                $('#login-form').on('submit', function () {
                    console.log('submit');
                    that.login();
                    return false;
                });
            },
            login: function () {
                // $('#login-form').data('bootstrapValidator').validate();
                // var b = $('#login-form').data('bootstrapValidator').isValid();
                // if (!b) {
                //     return false;
                // }
                $('#btn-login').attr('disabled', 'disabled');
                $('#a_login').attr('disabled', 'disabled');
                $.ajax({
                    url: '${ctxPath}/sys/user/login',
                    type: 'post',
                    dataType: 'json',
                    data: $('#login-form').serialize(),
                    success: function (data) {
                        if (data.status) {
                            if ($('input[type=checkbox][name=rememberMe]:checked').val() === '1') {
                                $.cookie('username', $('#username').val(), {expires: 7});
                                $.cookie('password', $('#password').val(), {expires: 7});
                            } else {
                                $.cookie('username', '');
                                $.cookie('password', '');
                            }
                            layer.msg(data.msg, {icon: 1});
                            setTimeout(function () {
                                top.location.replace('${ctxPath}/sys/index/index');
                            }, 1500);
                            //wpgaci.goUrl('/sys/index/index', 2)
                        } else {
                            $('#btn-login').removeAttr('disabled');
                            $('#a_login').removeAttr('disabled');
                            layer.msg(data.msg, {icon: 2});
                        }
                    },
                    error: function () {
                        $('#btn-login').removeAttr('disabled');
                        $('#a_login').removeAttr('disabled');
                        layer.msg('网络错误，请稍后再试', {icon: 2});
                    }
                });
            }
        };
    </script>
</div>
@};
@include('../../layout/_open_content.html',{content:content}){}